#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int int_cmp(const void*p1,const void*p2)
{
	return (*(int*)p1 - *(int* )p2);
}

void _swap(void*p1,void*p2,int size)
{
	int i = 0;
	for (i = 0; i < size; i++)
	{
		char mid = *((char*)p1 + i);
		*((char*)p1 + i) = *((char*)p2 + i);
		*((char*)p2 + i) = mid;
	}
}

void bulle(void* num, int count, int size, int(*cmp)(void*, void*))
{
	int i = 0;
	int j = 0;
	for (i = 0; i < count - 1; i++)
	{
		for (j = 0; j < count - 1 - i; j++)
		{
			if (cmp((char*)num + j * size, (char*)num + (j + 1) * size) > 0)
			{
				_swap((char*)num + j * size, (char*)num + (j + 1) * size, size);
			}
		}
	}
}

int main()
{
	int arr[10] = { 1,5,4,3,2,8,7,6,9,0 };
	int i = 0;
	bulle(arr, sizeof(arr) / sizeof(arr[0]), sizeof(int), int_cmp);
	for (i = 0; i < 10; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}